﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VRacer.Packets
{
    public class MessagePacket : PlayerPacket
    {
        private string _message;

        public MessagePacket()
            : base(PacketType.Message)
        {

        }

        public MessagePacket(int from, string message)
            : this()
        {
            this.ID = from;
            _message = message;
        }

        public MessagePacket(PlayerBase from, string message)
            : this()
        {
            this.ID = from.ID;
            _message = message;
        }

        public string Message
        {
            get { return _message; }
            set { _message = value; }
        }

        public override void Read(System.IO.BinaryReader reader)
        {
            base.Read(reader);

            _id = reader.ReadInt32();
            _message = reader.ReadString();
        }

        public override void Write(System.IO.BinaryWriter writer)
        {
            base.Write(writer);

            writer.Write(_id);
            writer.Write(_message);
        }
    }
}
